﻿using System;
using System.Collections.Generic;

using System.Text;
using System.Threading.Tasks;

namespace ArrayTraining
{
    class Program
    {
        static void Main(string[] args)
        {
            //string[] season = new string[]
            //  {
            //        "Январь",
            //        "Февраль",
            //        "Март",
            //        "Апрель",
            //        "Май",
            //        "Июнь",
            //        "Июль",
            //        "Август",
            //        "Сентябрь",
            //        "Октябрь",
            //        "Ноябрь",
            //        "Декабрь",

            //  };
            // string[] season2 = new string[14];

            //season.CopyTo(season2, 1);
            //foreach (var name in season2)
            //{
            //    Console.WriteLine(name);
            //}
            //string[] season3 = new string[6];
            //Array.Copy(season,season3, 0);
            //foreach (var name in season3)
            //{
            //    Console.WriteLine(name);
            //}
            //Array.Reverse(season);
            //foreach (var name in season)
            //{
            //    Console.WriteLine(name);
            //}
            // int indOfNov = Array.IndexOf(season, "Ноябрь");
            // Console.WriteLine(indOfNov);
            //Array.Sort(season, new MyCustomStringComparer());
            //foreach (var name in season)
            //{
            //    Console.WriteLine(name);
            //}
            //string[] allStartA = Array.FindAll(season, x => x[0] == 'А');
            //foreach (var name in allStartA)
            //{
            //    Console.WriteLine(name);
            //}
            //string[] lengthLess4 = Array.FindAll(season, x => x.Length < 5);
            //foreach (var name in lengthLess4)
            //{
            //    Console.WriteLine(name);
            //}
            Car car1 = new Car()
            {
                Brand = "Mercedes",
                Cost = 10000,
                Color = "blue",
                Year = 1990,
                Model = "S 600",

            };
            Car car2 = new Car()
            {
                Brand = "Audi",
                Cost = 20000,
                Color = "red",
                Year = 1982,
                Model = "A3",

            };
            Car car3 = new Car()
            {
                Brand = "Renault",
                Cost = 5000,
                Color = "black",
                Year = 1998,
                Model = "Duster",

            };
            Car car4 = new Car()
            {
                Brand = "BMV",
                Cost = 40000,
                Color = "black",
                Year = 2000,
                Model = "X5",

            };
            Car car5 = new Car()
            {
                Brand = "BMV",
                Cost = 45000,
                Color = "red",
                Year = 2003,
                Model = "X6",

            };
            Car car6 = new Car()
            {
                Brand = "Audi",
                Cost = 35000,
                Color = "silver",
                Year = 1998,
                Model = "A3",

            };

            Car car7 = new Car()
            {
                Brand = "BMW",
                Cost = 33000,
                Color = "white",
                Year = 2003,
                Model = "i3",

            };
            Car car8 = new Car()
            {
                Brand = "Mazda",
                Cost = 22000,
                Color = "white",
                Year = 2004,
                Model = "6",

            };
            Car car9 = new Car()
            {
                Brand = "Mazda",
                Cost = 24000,
                Color = "blue",
                Year = 2004,
                Model = "3",

            };



           Car[] carArray = new Car[9];

            carArray[0] = car1;
            carArray[1] = car2;
            carArray[2] = car3;
            carArray[3] = car4;
            carArray[4] = car5;
            carArray[5] = car6;
            carArray[6] = car7;
            carArray[7] = car8;
            carArray[8] = car9;

            //Car[] selectedCar = Array.FindAll(carArray, x => x.cost < 15000);
            //foreach (var name in selectedCar)
            //{
            //    Console.WriteLine(name);
            //}
            Car[] selectedMers = Array.FindAll(carArray, x => x.Brand == "Mercedes" | x.Brand == "Audi");
            //foreach (var name in selectedMers)
            //{
            //    Console.WriteLine(name);
            //
            Car[] selectedAudiA3 = Array.FindAll(carArray, x => x.Brand == "Audi" & x.Model == "A3");
            //foreach (var name in selectedAudiA3)
            //{
            //    Console.WriteLine(name);
            //}
            Car[] selectedRedNotAudi = Array.FindAll(carArray, x => x.Brand != "Audi" && x.Color == "red" && x.Cost>15000 && x.Cost < 55000);
            foreach (var name in selectedRedNotAudi)
            {
                Console.WriteLine(name);
            } 

        }

        class Car
        {
            //public string brand;
            //public int cost;
            //public string color;
            //public int year;
            //public string model;

            public string Brand { get; set; }
            public int Cost { get; set; }
            public string Color { get; set; }
            public int Year { get; set; }
            public string Model { get; set; }

            public override string ToString()
            {
                //return Brand + " " + Cost + " " + Color + " " + Year + " " + Model;

                StringBuilder builder = new StringBuilder();
                builder.AppendFormat("{0} {1} {2} {3} {4}", Brand, Cost, Color, Year, Model);
                string selCars = builder.ToString();
                return selCars;

            }
        }


    }
}


